function [IC2dfit,IniCond2d] = IniConditions2DFit(ODforfit)

% Using ODrawbin for 2D fitting IC
    [horizbin,vertbin] = size(ODforfit);  % y-dir. is HORIZ. exper. dir.; x-dir. is VERT
    IC2dfit.amp=max(max(ODforfit));
    [IC2dfit.yoff,IC2dfit.xoff] = find(ODforfit == IC2dfit.amp);
    IC2dfit.sigx=vertbin/10;
    IC2dfit.sigy=horizbin/10;
    
    %using a 3x3 pixel area to determine data offset and slope
    guessave=3; 
    guessleftup = sum(sum(ODforfit(1:guessave,1:guessave)))/guessave^2;
    guessleftdn = sum(sum(ODforfit(horizbin-guessave:horizbin,1:guessave)))/guessave^2;
    guessrightup = sum(sum(ODforfit(1:guessave,vertbin-guessave:vertbin)))/guessave^2;
    guessrightdn = sum(sum(ODforfit(horizbin-guessave:horizbin,vertbin-guessave:vertbin)))/guessave^2;
    
    IC2dfit.off = (guessleftup + guessleftdn + guessrightup + guessrightdn)/4 ;
    IC2dfit.slopex =((guessrightup + guessrightdn) - (guessleftup + guessleftdn))/(2*horizbin);
    IC2dfit.slopey =((guessleftdn + guessrightdn) - (guessrightup + guessleftup))/(2*vertbin);
    IniCond2d=[IC2dfit.off,IC2dfit.amp,IC2dfit.xoff,IC2dfit.yoff,IC2dfit.sigx,IC2dfit.sigy,IC2dfit.slopex,IC2dfit.slopey];
end
